package cn.com.huzo.repository.trade.impl;

import cn.com.huzo.model.entities.trade.DeliveryCommandSheetLinesEntity;
import cn.com.huzo.model.entities.trade.DeliveryCommandSheetLinesMoEntity;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import cn.com.huzo.repository.trade.DeliveryCommandSheetLinesRepository;
import java.util.HashMap;

/**
 * 发货发令单明细数据访问对象。
 *
 * @author 吴旭
 */
@Repository("DeliveryCommandSheetLinesRepository")
public class DeliveryCommandSheetLinesRepositoryImpl extends GenericRepositoryImpl<DeliveryCommandSheetLinesEntity, String>
        implements DeliveryCommandSheetLinesRepository {

    private final String namespace = "cn.com.huzo.repository.trade.DeliveryCommandSheetLinesRepository";

    /**
     * 构造函数,设置the entity to DeliveryCommandSheetHeaderRepositoryImpl.class.
     */
    public DeliveryCommandSheetLinesRepositoryImpl() {
        super(DeliveryCommandSheetLinesEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<DeliveryCommandSheetLinesEntity> fetchByHeaderId(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByHeaderId"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<DeliveryCommandSheetLinesEntity> fetchByHeaderIdAndStyleNo(Long headerId, String styleNo) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("HeaderId", headerId);
        criterion.put("StyleNo", styleNo);

        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByHeaderIdAndStyleNo"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<String> fetchAllSelectedLines(Map<String, Object> criterion) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchAllSelectedLines"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insert(DeliveryCommandSheetLinesMoEntity instance) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insert"), instance);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchUpdate(List<DeliveryCommandSheetLinesEntity> itemList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "update"), itemList);
    }

    /**
     * {@inheritDoc}
     * <p>
     */
    @Override
    public Integer delete(String key) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), key);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchDelete(List<DeliveryCommandSheetLinesEntity> itemList) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchDelete"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer deleteByLinesMo(Map<String, Object> criterion) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "deleteByLinesMo"), criterion);
    }

    // <editor-fold defaultstate="collapsed" desc="款号顺序操作">
    /**
     * {@inheritDoc}
     */
    @Override
    public List<Map<String, Object>> fetchLinesStyleNoOrderByHeaderId(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchLinesStyleNoOrderByHeaderId"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insertLinesStyleNoOrder(Long headerId) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insertLinesStyleNoOrder"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer updateLinesStyleNoOrder(List<Map<String, Object>> itemList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "updateLinesStyleNoOrder"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer deleteLinesStyleNoOrder(Long headerId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "deleteLinesStyleNoOrder"), headerId);
    }
    // </editor-fold>
}
